package com.wolf.cx330.view.act

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.wolf.cx330.R
import com.wolf.cx330.view.view.ECGView
import kotlinx.android.synthetic.main.activity_ecg.*
import java.util.*

class EcgAct : AppCompatActivity() {

    companion object {
        fun actionStart(context: Context) =
            context.startActivity(Intent(context, EcgAct::class.java))
    }

    val list = listOf(
        500,
        400,
        300,
        500,
        100,
        300,
        400,
        500,
        200,
        233,
        343,
        453,
        653,
        763,
        233,
        433,
        543,
        563,
        133,
        343,
        643,
        763,
        863,
        343,
        543,
        653,
        243,
        353,
        463,
        673,
        373,
        483,
        533,
        212,
        234,
        345,
        236,
        217,
        233,
        123,
        143,
        253,
        243,
        253,
        263,
        273,
        273,
        283,
        333,
        312,
        234,
        245,
        236,
        217,
        233,
        123,
        145,
        136,
        117,
        133,
        223,
        500,
        400,
        300,
        500,
        100,
        300,
        400,
        500,
        200,
        233,
        343,
        453,
        653,
        763,
        233,
        433,
        543,
        563,
        133,
        343,
        643,
        763,
        863,
        343,
        543,
        653,
        243,
        353,
        463,
        673,
        373,
        483,
        533,
        212,
        234,
        345,
        236,
        217,
        233,
        123,
        143,
        253,
        243,
        253,
        263,
        273,
        273,
        283,
        333,
        312,
        234,
        245,
        236,
        217,
        233,
        123,
        145,
        136,
        117,
        133,
        223,
        500,
        400,
        300,
        500,
        100,
        300,
        400,
        500,
        200,
        233,
        343,
        453,
        653,
        763,
        233,
        433,
        543,
        563,
        133,
        343,
        643,
        763,
        863,
        343,
        543,
        653,
        243,
        353,
        463,
        673,
        373,
        483,
        533,
        212,
        234,
        345,
        236,
        217,
        233,
        123,
        143,
        253,
        243,
        253,
        263,
        273,
        273,
        283,
        333,
        312,
        234,
        245,
        236,
        217,
        233,
        123,
        145,
        136,
        117,
        133,
        223
    )
    var i = 0
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_ecg)
        Timer().schedule(object : TimerTask() {
            override fun run() {
                if (i < list.size) {
                    runOnUiThread {
                        ecgView.addVal(ECGView.ECGData(list[i] / 100F, "测试"))
                        i++
                    }
                }

            }
        }, 1000, 1050)
    }
}